package #(table.packageName).domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.sql.Types;

import lombok.Data;
import lombok.experimental.FieldNameConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import org.sagacity.sqltoy.config.annotation.Entity;
import org.sagacity.sqltoy.config.annotation.Id;
import org.sagacity.sqltoy.config.annotation.Column;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

#if(option.isGenExport())
import com.rankeiot.core.anno.Excel;
#end

/**
* #(table.title)
*/
@Schema(description="#(table.title)")
@Data
@FieldNameConstants(asEnum = true)
@Entity(tableName=#(table.name).TABLE)
public class #(table.name) implements Serializable{
    public static final String TABLE="#(table.code)";

    #for(column:table.columns)
    /**
    * #(column.name)
    */
    @Schema(description="#(column.name)")
    #if(column.isPrimaryKey())
    #if(column.dataType=='String')
    @Id(strategy = "generator",generator = "snowflake")
    #else
    @Id(strategy = "identity")
    #end
    #else if(column.isMandatory())
    @NotNull
    #end
    #if(column.dataType=='String')
    @Length(max=#(column.length))
    #end
    #if(option.isGenExport())
    #if(column.dict||column.translate)
    #if(!option.isGenFormVo())
    @Excel("#(column.name)")
    #end
    #else
    @Excel("#(column.name)")
    #end
    #end
    @Column(name="#(column.code)",length=#(column.length)L,type=Types.#(column.type)#if(column.isMandatory()),nullable=false#end#if(column.isAutoIncrement()),autoIncrement=true#end)
    private #(column.dataType) #(column.field);
    #end

    public #(table.name)(){}
    public #(table.name)(#(table.pkArgs())){
    #for(column:table.columns)#if(column.isPrimaryKey())
        this.#(column.field)=#(column.field);
    #end#end
    }
}
